//
//  BCSafeCenterBaseCell.m
//  GSBlockChain
//
//  Created by guoshikeji_a on 2018/11/26.
//  Copyright © 2018 guoshikeji. All rights reserved.
//

#import "BCSafeCenterBaseCell.h"

static CGFloat BCSafeCenterBaseCellTitleHeight = 50.0f;

@implementation BCSafeCenterBaseCell

- (UILabel *)rightDetailLabel {
    if (!_rightDetailLabel) {
        _rightDetailLabel = [UILabel new];
        _rightDetailLabel.textColor = [UIColor qmui_colorWithHexString:@"#AEAEAE"];
        _rightDetailLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightRegular];
        [self.contentView addSubview:_rightDetailLabel];
        [_rightDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(self.contentView).offset(-15.0);
            make.centerY.mas_equalTo(self.contentView);
        }];
    }
    return _rightDetailLabel;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupBaseViews];
    }
    return self;
}
- (void)setupBaseViews {
    self.titleLabel = [UILabel new];
    self.titleLabel.textColor = [UIColor qmui_colorWithHexString:@"#333333"];
    self.titleLabel.font = [UIFont systemFontOfSize:17 weight:UIFontWeightRegular];
    [self.contentView addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.contentView).offset(15.0);
        make.top.mas_equalTo(self.contentView);
        make.height.mas_equalTo(BCSafeCenterBaseCellTitleHeight);
    }];
    
    [self addSubview:self.separatorLine];
    [self.separatorLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.contentView).offset(10.0);
        make.right.mas_equalTo(self.contentView).offset(-10.0);
        make.height.mas_equalTo(1.0);
        make.bottom.mas_equalTo(self);
    }];
}

- (void)setCellModel:(BCSafeCenterCellModel *)cellModel {
    _cellModel = cellModel;
    //
    self.titleLabel.text = cellModel.title;
    
    //
    if (cellModel.details.length) {
        self.rightDetailLabel.text = cellModel.details;
    }
}


+ (CGFloat)defaultHeight {
    return BCSafeCenterBaseCellTitleHeight;
}

@end
